\begin{appendices}
	\section{Python 源代码}
	下面给出问题二中利用DFT求解系数(并计算了插值函数的值)的Python源码:
	\begin{lstlisting}[language=python]
import numpy as np

f_s = [0] * 6 + [11] * 8 + [-3] * 4 + [11] * 8 + [0] * 2

F = np.fft.fft(f_s)
N = len(f_s)  

a0 = 2 * F[0].real / N
an = [2 * F[n].real / N for n in range(1, N//2)]
bn = [-2 * F[n].imag / N for n in range(1, N//2)]
a14 = F[N//2].real / N  

a0_round = np.round(a0, 2)
an_round = np.round(an, 2)
bn_round = np.round(bn, 2)
a14_round = np.round(a14, 2)


print(" 系数:")
print(f"a0 = {a0_round}\n")
print("an:")
for i, a in enumerate(an_round, 1):
    print(f"  a{i} = {a}")
print("\n bn:")
for i, b in enumerate(bn_round, 1):
    print(f"  b{i} = {b}")
print(f"\n a14 = {a14_round}\n")

def f(t):

    result = a0_round / 2
    for n in range(1, N//2):
        theta = n * np.pi * t / 14  
        result += an_round[n-1] * np.cos(theta) + bn_round[n-1] * np.sin(theta)
    result += a14_round * np.cos(np.pi * t)  
    return result


print("检验:")
for k in range(N):
    fk_c = np.round(f(k), 4) 
    fk_e = f_s[k]
    print(f"t = {k:2d}: 函数值 = {fk_c:6.2f}, 期望值 = {fk_e:2d}")
	\end{lstlisting}
\end{appendices}